<%@ page import="com.cxl.entity.User" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: 20971
  Date: 2021/12/30
  Time: 15:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>详情</title>
    <link rel="stylesheet" href="resource/css/bootstrap.css">
    <script type="text/javascript" src="resource/js/jquery-3.2.1.js"></script>
</head>
<body>
<form:form modelAttribute="c" method="post" action="list">
    <table class="table table-hover">
        <tr>
            <td>课程名称</td>
            <td>${c.cname}</td>
        </tr>
        <tr>
            <td>课程图标</td>
            <td>
                <img src="${c.pic}" width="200" height="140">
            </td>
        </tr>
        <tr>
            <td>课程分类</td>
            <td>${c.tname}</td>
        </tr>
        <tr>
            <td>课程发布日期</td>
            <td>
                <fmt:formatDate value="${c.putdate}" pattern="yyyy-MM-dd"></fmt:formatDate>
            </td>
        </tr>
        <tr>
            <td>课程发布者</td>
            <td>${c.uname}</td>
        </tr>
        <tr>
            <td>视频简介视频</td>
            <td>
                <video width="300" height="150" autoplay="autoplay"
                    src="/pic${c.video}"
                ></video>
            </td>
        </tr>
    </table>

    <div>
        <nav>
            <div class="nav nav-tabs" id="nav-tab" role="tablist">
                <a onclick="toindex(1)" class="nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">好评${com.praise}</a>
                <a onclick="toindex(2)" class="nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">中评${com.medium}</a>
                <a onclick="toindex(3)" class="nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">差评${com.negative}</a>
            </div>
        </nav>
        <div class="tab-content" id="nav-tabContent">

        </div>
    </div>

    <table class="table table-hover">
        <tr>
            <td>评论分值</td>
            <td>
                <input type="text" name="score" placeholder="请输入1-10之间的数字">
            </td>
        </tr>
        <tr>
            <td>评论内容</td>
            <td>
                <textarea name="content" placeholder="请输入评论内容"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <%
                    User user = (User) request.getSession().getAttribute("LONGUSER");
                %>
                <input type="hidden" name="uid" value="<%=user.getUid()%>">
                <input type="hidden" name="cid" value="${c.cid}">
                <input type="button" value="发布评论" onclick="tocomments()">
            </td>
        </tr>
    </table>
</form:form>

<script>

    $(function () {
        toindex(1);
    })
    /*载入[评论信息*/
    function toindex(val) {
        $("#nav-tabContent").load("getcomment?rid="+val+"&cid=${c.cid}");
    }
    
    //发布评论
    function tocomments() {
        location.href = "getdetails?"+$("form").serialize();
    }
</script>
</body>
</html>
